package com.hontech.kaltaapp.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.kaltaapp.R
import com.hontech.kaltaapp.device.nozzleCtrl
import com.hontech.kaltaapp.ui.dialog.runProg
import com.hontech.kaltaapp.ui.dialog.runProgMsg
import com.hontech.kaltaapp.ui.view.LabelInput
import com.hontech.kaltaapp.utils.onClick

class NozzleParts (context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_nozzle, this)
        val liMm = view.findViewById<LabelInput>(R.id.id_nozzle_li_mm)
        val btnCtrl = view.findViewById<Button>(R.id.id_nozzle_btn_ctrl)
        val btnReset = view.findViewById<Button>(R.id.id_nozzle_btn_reset)

        btnCtrl.onClick {
            runProg("喷嘴", "控制") {
                nozzleCtrl(liMm.textInt())
            }
        }
        btnReset.onClick {
            runProg("喷嘴", "复位") {
                nozzleCtrl(0)
            }
        }
    }
}